<?php
/** ******************************************************************************
 * 
 * This file is under copyright of Zeedler Ztudio. Do not be modified or amended,
 * To study or co-source code. Can be contacted at administrator@zeedler.net.
 * Or visit the information. www.zeedler.com and www.zeedler.net.
 * 
 ********************************************************************************/ 
include("../config.ini.php");
include("../globaltools.php");

$username = "administrator";
$password = md5("252920");
$admingender = "male";
$firstname = "ภาสพงษ์";
$lastname = "ชาญเชี่ยว";

$connect = Ztools::connectdb(__dbhost__, __dbuser__, __dbpass__, __dbname__, __charset__);

$gender[0] = array(0=>"1", 1=>"male");
$gender[1] = array(0=>"2", 1=>"female");
$gender[2] = array(0=>"3", 1=>"gay");
$sql = "insert into `".$mysql_table["genders"]."` (`code`, `order`, `name`) values ";
for ($i=0; $i<=(count($gender)-1); $i++) {
	$key = Ztools::keygen(3, 3, 1, 1, 0);
	if ($admingender == $gender[$i][1]) { $admingender = $key; }
	$sql .= "('$key', '".$gender[$i][0]."', '".$gender[$i][1]."')";
	if ($i != (count($gender)-1)) $sql .= ",\n";
	elseif ($i == (count($gender)-1)) $sql .= ";";
}
Ztools::mysql_query($sql, 0);

$groups[0] = array(0=>"1", 1=>"Guest");
$groups[1] = array(0=>"2", 1=>"Admin");
$groups[2] = array(0=>"3", 1=>"Assistant");
$groups[3] = array(0=>"4", 1=>"Teacher");
$groups[4] = array(0=>"5", 1=>"Student");
$sql = "insert into `".$mysql_table["groups"]."` (`code`, `order`, `name`) values";
for ($i=0; $i<=(count($groups)-1); $i++) {
	$key = Ztools::keygen(3, 3, 1, 1, 0);
	if ($i == 1) { $adminkey = $key; }
	$sql .= "('$key', '".$groups[$i][0]."', '".$groups[$i][1]."')";
	if ($i != (count($groups)-1)) $sql .= ",\n";
	elseif ($i == (count($groups)-1)) $sql .= ";";
}
Ztools::mysql_query($sql, 0);

$membercode = Ztools::keygen(30, 30, 1, 1, 0);
$sql = "insert into `".$mysql_table["login"]."` (`members_code`, `username`, `password`, `groups`) values ";
$sql .= "('$membercode', '$username', '$password', '$adminkey')";
Ztools::mysql_query($sql, 0);

$sql = "insert into `".$mysql_table["members_data"]."` (`members_code`, `gender`,";
$sql .= " `firstname`, `lastname`) values ('$membercode', '$admingender', '$firstname', '$lastname')";
Ztools::mysql_query($sql, 0);

@mysql_close($connect);
Ztools::cleanVar();
?>